package com.zxg.threed.controller;

import com.zxg.threed.model.UserModel;
import com.zxg.threed.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller("user")
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    //获取前端穿过来的参数
    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public ModelAndView login(@RequestParam(name = "name") String name, @RequestParam(name = "password") String password){
        UserModel login = userService.login(name, password);
        if (login==null){
            ModelAndView modelAndView=new ModelAndView("admin/admin/login");
            return modelAndView;
        }
        return new ModelAndView("admin/admin/index");
    }
    @RequestMapping("/loginpage")
    public ModelAndView loginpage(){
        ModelAndView modelAndView=new ModelAndView("admin/admin/login");
        return modelAndView;
    }
    //返回home界面
}
